import { defHttp } from "/@/utils/http/axios";

import { ErrorMessageMode } from "/#/axios";
import { UserInfo } from "/#/store";

enum Api {
  Login = "/login",
  Logout = "/logout",
  GetUserInfo = "/getInfo",
  GetRoles = "/getRoles",
}

/**
 * @description: user login api
 */
export function loginApi(mode: ErrorMessageMode = "modal") {
  return defHttp.get(
    {
      url: Api.Login,
    },
    {
      errorMessageMode: mode,
      isReturnNativeResponse: true,
    },
  );
}

/**
 * @description: getUserInfo
 */
export function getUserInfo() {
  return defHttp.get<UserInfo>({ url: Api.GetUserInfo }, { errorMessageMode: "none" });
}

export function getRoles() {
  return defHttp.get<string[]>({ url: Api.GetRoles });
}

export function doLogout() {
  return defHttp.get({ url: Api.Logout });
}
